<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // 授权账号信息
        Schema::create('wxauthorizers', function (Blueprint $table) {
            $table->id();
            $table->string('appid', 32)->nullable(false);
            $table->integer('apptype')->nullable(false)->default(0);
            $table->integer('servicetype')->nullable(false)->default(0);
            $table->string('nickname', 32)->nullable(false)->default('');
            $table->string('username', 32)->nullable(false)->default('');
            $table->string('headimg', 256)->nullable(false)->default('');
            $table->string('qrcodeurl', 256)->nullable(false)->default('');
            $table->string('principalname', 64)->nullable(false)->default('');
            $table->string('refreshtoken', 128)->nullable(false)->default('');
            $table->string('funcinfo', 128)->nullable(false)->default('');
            $table->integer('verifyinfo')->nullable(false)->default(-1);
            $table->timestamp('auth_at')->nullable(false);
            $table->timestamp('update_at')->default(DB::raw('CURRENT_TIMESTAMP'))->useCurrentOnUpdate();
            $table->unique('appid');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('wxauthorizers');
    }
};
